package com.dave.dubbo.provider.service.impl;

import cn.hutool.core.date.DateUtil;
import com.dave.dubbo.provider.api.EmailService_2_7_8;
import com.dave.dubbo.provider.api.entity.UserTest;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author wangwj
 * @version 1.0
 * @date 2021/12/16
 * @description: TODO
 */
@Slf4j
@Component
@DubboService(version = "1.0.0",group = "aa")
public class EmailServiceImpl implements EmailService_2_7_8 {


    @Value("${spring.application.name}")
    private String serviceName;

    @Override
    public String sendEmail(String title) {
        log.info("收到请求参数: {}", title);
        return String.format("[%s] : %s ,已发送，谢谢使用!", title, serviceName);
    }

    @Override
    public UserTest sendEmail() {
        UserTest userTest =  new UserTest();
        userTest.setId("2");
        userTest.setName("收到请求");
        userTest.setDatetime(DateUtil.formatDateTime(new Date()));
        return userTest;
    }
}
